package AC;

public class Teacher {
    private  int age;
    private  String schoolname;
    private String name;

    public Teacher(int age, String schoolname, String name) {
        this.age = age;
        this.schoolname = schoolname;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) throws Exception {
        if(age>=22){
            this.age = age;
        }else {
            throw new Exception("年龄有误！");
        }
    }
    public String getSchoolname() {
        return schoolname;
    }

    public void setSchoolname(String schoolname) {
        this.schoolname = schoolname;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public  void  self(){
        System.out.println("我的名字是："+name+"我在"+schoolname+"上课");
    }
    public  void shangke(){
        System.out.println(schoolname+"的"+name+"老师在上课");
    }
}
